<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{.Title}}</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<header>
    <div class="container">
        <h1>短链生成工具</h1>
        <nav>
            {{if .User}}
            {{if eq .PageType "index"}}
            <a href="/url/list">我的记录</a>
            {{end}}
            {{if eq .PageType "records"}}
            <a href="/url/createPage">生成短链</a>
            {{end}}
            <span>欢迎，{{.User.Username}}</span>
            <a href="/auth/logout">退出</a>
            {{else}}
            <a href="/auth/loginPage">登录</a>
            <a href="/auth/registerPage">注册</a>
            {{end}}
        </nav>
    </div>
</header>

<!-- 内容区域（根据页面类型显示对应块） -->
<main class="container">
    {{if .Error}}
    <div class="alert error">{{.Error}}</div>
    {{end}}
    {{if .Success}}
    <div class="alert success">{{.Success}}</div>
    {{end}}

    <!-- 登录页内容块 -->
    {{if eq .PageType "login"}}
    {{block "login" .}}{{end}}
    {{end}}

    <!-- 注册页内容块 -->
    {{if eq .PageType "register"}}
    {{block "register" .}}{{end}}
    {{end}}

    <!-- 短链生成页内容块 -->
    {{if eq .PageType "create"}}
    {{block "index" .}}{{end}}
    {{end}}

    <!-- 短链列表页内容块 -->
    {{if eq .PageType "records"}}
    {{block "records" .}}{{end}}
    {{end}}

</main>

<footer>
    <div class="container">
        <p>&copy; 2025 短链生成工具</p>
    </div>
</footer>

<script src="/static/js/main.js"></script>
</body>
</html>